package com.bana.fvs.app.mvp.presenter;

import android.app.Activity;

import com.bana.fvs.app.main.entity.UserInfoBean;
import com.bana.fvs.app.module.detaile.entity.CommonEntity;
import com.bana.fvs.app.mvp.contract.MainContract;
import com.bana.fvs.app.mvp.model.MainModel;
import com.bana.fvs.app.util.UserInfoUtils;
import com.wei.commonlibrary.net.CommException;
import com.wei.commonlibrary.net.MyDefaultCallback;

public class MainPresenter extends MainContract.AbsMainPresenter {
    @Override
    public void validate(Activity activity) {

        String token= UserInfoUtils.getInstance().getToken(activity);

        mModel.validate(token).callback(new MyDefaultCallback<CommonEntity>(activity, true) {
            @Override
            public void onError(CommException e) {
                if (null != getView())
                    getView().onError(e);
            }

            @Override
            public void response(CommonEntity entity) {
                if (null != getView())
                    getView().onTokenRefresh(entity);
            }
        });
    }

    @Override
    protected MainContract.AbsMainModel createModel() {

        return new MainModel();
    }
}
